import pandas as pd
from selenium import webdriver
import time


def http_requests():
    client.get("https://spa4.scrape.center/")
    time.sleep(2)
    html = client.page_source
    return html


def re_(html):
    c = []
    import re
    a = re.compile("""<a data-v-04056655="" href="(?P<href>.*?)" target="_blank" class="m-l-sm">(?P<title>.*?)</a>""")
    data = a.findall(html)
    b = re.compile("""<p data-v-04056655="" class="info m-l-md"><span data-v-04056655="">(.*?)
              </span><!----></p>""")
    datab = b.findall(html)
    for match in data:
        href = match[0]
        title = match[1]
        Datafull = href, title, datab[0]
        c.append(Datafull)
    return c


def main():
    import pandas
    html = http_requests()
    data = re_(html)
    print(data)
    df = pd.DataFrame(data)
    df.to_csv("main.csv", mode='w', index=False)


if __name__ == "__main__":
    client = webdriver.Chrome()
    main()
